package com.prs.crm.dao.stock.impl;

import java.util.Collection;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

import com.prs.crm.dao.impl.BaseDaoImpl;
import com.prs.crm.dao.stock.StockAlertDao;
import com.prs.crm.domain.stock.Product;
import com.prs.crm.domain.stock.StockAlert;
import com.prs.crm.domain.store.StoreRoom;

public class StockAlertDaoImpl extends BaseDaoImpl<StockAlert> implements StockAlertDao{

	@SuppressWarnings("unchecked")
	@Override
	public Collection<StockAlert>getOnestockAlert(Product product, StoreRoom storeRoom) {
		Criteria criteria=this.getSession().createCriteria(StockAlert.class);
		criteria.add(Restrictions.eq("product", product)).add(Restrictions.eq("storeRoom", storeRoom));
		return criteria.list();
	}

	@SuppressWarnings("unchecked")
	@Override
	public Collection<StockAlert> getStockAlertsByProduct(Product product) {
		Criteria criteria=this.getSession().createCriteria(StockAlert.class);
		criteria.add(Restrictions.eq("product", product));
		return criteria.list();
	}
	public Collection<StockAlert> getAllStockAlerts() {
		Criteria criteria=this.getSession().createCriteria(StockAlert.class);
		return criteria.list();
	} 

	
}
